[SQL]Summing a column while ignoring duplicate records(row_number())


SELECT custid, SUM(amount)
FROM (SELECT t.*,
             ROW_NUMBER() OVER (PARTITION BY custid, transid ORDER BY transid) AS seqnum
      FROM table_1 t
     ) t
WHERE seqnum = 1;
#SQL






你可能感興趣的文章

AI輔導室|製作圓形漢字印鑑效果

AI輔導室|製作圓形漢字印鑑效果

DEC 14 2023 PROCL-5: User does not have permission to perform a local registry operation on this key. Authentication error [User [root] [已解決]

DEC 14 2023 PROCL-5: User does not have permission to perform a local registry operation on this key. Authentication error [User [root] [已解決]

JS 時間日期處理

JS 時間日期處理






留言討論